<template>
	<view class="container" >
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog type="info"  confirmText="一键登录"  cancelText="返回" title="请登录后，获取需求"
				@close="dialogClose" @confirm="dialogConfirm"  @getphonenumber="dialogConfirm">
		    </uni-popup-dialog>
		</uni-popup>
		<view class="header">
			<view class="left-icon"></view>
			<image class="avatar"
				:src="demandInfo.nocUser && demandInfo.nocUser.portrait ? demandInfo.nocUser.portrait : '/static/image/wutouxiang.png'"
				mode="widthFix" />
			<view class="username">
				{{demandInfo.userName}}
			</view>
			<image v-if="demandInfo.isShowPhone== 1 && demandInfo.ifPhone == 1"
				style="width:68rpx;height: 68rpx;margin-left: 150rpx;" @click="toCall()"
				src="https://m.nocexpo.com/statics/js/modules/h5/img/dianhua.png" />
			<image v-if="demandInfo.isShowPhone== 1" style="width:68rpx;height: 68rpx;margin-left: 30rpx;"
				@click="sendMsg()" src="https://m.nocexpo.com/statics/js/modules/h5/img/xinxi.png" />
		</view>
		<view class="scroll-view" scroll-y>
			<view class="module">
				<view class="title">
					<view v-if="demandInfo.classifyName != null" class="text">
						<image class="rz" v-show="demandInfo.ifAttestation  == 1" src="https://m.nocexpo.com/statics/js/modules/h5/img/renzheng.png"
							mode="heightFix" />
						<image class="rz1" v-show="demandInfo.ifMember  == 1" :src="imgUrl + '/statics/js/modules/applet/img/vipp.png'">1</image>
						{{demandInfo.classifyName}}: {{demandInfo.title}}
					</view>
					<view v-else class="text">
						<image class="rz" src="https://m.nocexpo.com/statics/js/modules/h5/img/renzheng.png" mode="heightFix" />寻求: {{demandInfo.title}}
					</view>
					<image v-if="demandInfo.demandState == 1" class="rightImg" src="https://m.nocexpo.com/statics/js/modules/h5/img/pipeizhong.png"
						mode="heightFix" />
					<image v-else-if="demandInfo.demandState == 2" class="rightImg" src="https://m.nocexpo.com/statics/js/modules/h5/img/duijiezhong.png"
						mode="heightFix" />
					<image v-else-if="demandInfo.demandState == 3" class="rightImg" src="https://m.nocexpo.com/statics/js/modules/h5/img/chenggong.png"
						mode="heightFix" />
				</view>
				<view class="attr" style="margin-top: 10rpx;"><text>需求描述：</text><view style="white-space: pre-line" v-html="demandInfo.content"></view></view>
				<view style="display: flex; justify-content: center; margin-top: 10rpx;">
					<view class="attr" style="width: 200rpx; position: relative;">
						<view class="" style="position: absolute; left: -2px; width: 122rpx;">
							<view style="color: #A1A0A0;font-size: 13px; text-align: center;">采购数量</view>
							<view style="text-align: center;">{{demandInfo.quantity||"暂无"}}</view>
						</view>
					</view>
					<view class="attr" style="width: 266rpx; border-left: 1px solid #F7F7F7; border-right: 1px solid #F7F7F7;">
						<view style="color: #A1A0A0;font-size: 13px; text-align: center;">采购预算</view>
						<view style="text-align: center;">{{demandInfo.priceStart||"暂无"}}-{{demandInfo.priceEnd ||"暂无"}}</view>
					</view>
					<view class="attr" style="width: 250rpx; text-align: center;">
						<view style="color: #A1A0A0;font-size: 13px;">采购区域</view>
						{{demandInfo.origin||"暂无"}}
					</view>
				</view>
				<!-- 标签 -->
				<view class="tags">
          <!-- v-show="index < 3" -->
					<view @click="goTagNews(item)" v-for="(item,index) in demandInfo.tagList"
						class="t">#{{item.tagName}}</view>
				</view>
				<!-- 发布时间 -->
				<view v-if="demandInfo.auditAt != null" class="attr">
					<text>发布时间：</text>{{demandInfo.auditAt}}
					<text style="margin-left: 15rpx;">ID：</text>{{demandInfo.id}}
				</view>
				<view v-else class="attr"><text>发布时间：</text>{{demandInfo.createAt}}</view>
				<!-- 缺少显示需求视频图片 -->
				<view class="images" v-if="demandInfo.videoUrl != null && demandInfo.videoUrl != ''">
					<video class="img" v-for="(video,index) in demandInfo.videoList" :src="video" />
				</view>
				<view class="images" v-if="demandInfo.pictureUrl != null && demandInfo.pictureUrl != ''">
					<image mode="widthFix" class="img" role="img" v-for="(img,index) in demandInfo.imgList"
						:src="img" />
				</view>
			</view>
			<view class="flowbox">
				<image  class="tu" :src="imgUrl +'/statics/js/modules/applet/img/jiedanliucheng.png'" mode=""></image>

			</view>

			<view v-if="!(demandInfo.ifDistribution == 1 && demandInfo.ifPurchase == 0)">
				<view v-if="demandInfo.demandState != 1" style="display: flex;">
				</view>
				<view class="shop-list-data">
				<view class="" v-if="demandInfo.demandState==1" style="font-size: 32rpx;margin-left:10rpx;font-weight: 600; margin-bottom: 10rpx;">匹配中
				(<text style="color:red;">{{demandInfos}}</text>)
				</view>
				<view class="" v-if="demandInfo.demandState==2" style="font-size: 32rpx;margin-left:10rpx;font-weight: 600;margin-bottom: 10rpx;">匹配成功
				(<text style="color:red">{{pipei}}</text>)
				</view>
					<view class="item" v-for="item in compList" :key="item.productEntities.id"
						v-show="item.productEntities.length>0">
						<view class="head">
							<image class="avatar"
								:src="item.nocUserEntity.logo ? item.nocUserEntity.logo : '/static/image/wutouxiang.png'"
								mode="widthFix" />
							<view class="info">
								<view class="title">
									{{item.nocUserEntity.company ? item.nocUserEntity.company.substring(0,20) : ''}}
									<view class="btn" @click="toShowroom(item.nocUserEntity.id)">进店</view>
								</view>
								<view class="attr">
									<view v-if="item.nocUserEntity.companyNature != null" class="tag">
										{{item.nocUserEntity.companyNature}}
									</view>
									曝光
									<view class="interval">{{item.nocCompanyDataVo.visitCount}}</view>
									对接用户
									<view class="interval">
										{{item.nocCompanyDataVo.dianzanCount + item.nocCompanyDataVo.collectCount}}
									</view>
									活跃
									<view class="interval">{{item.nocUserEntity.score}}</view>
								</view>
								<view class="grey"
									style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">主营：
									<view class="cls" v-for="(cls,index) in item.classifys" :key="cls">
										{{cls}}
										<view v-show="index != item.classifys.length -1" class="cls">|</view>
									</view>
								</view>
								<!-- <view v-for="(ee,index) in item.exhibitionEntity"
									:style="{background:(ee.fontBackgroundColor?ee.fontBackgroundColor:'#EBEDFF')},{color:(ee.fontColor ? ee.fontColor:'#6A76FF')}"
									class="main">{{ee.exhibitionShortName}}</view>
							</view> -->
							<view class="main" v-for="(ee,index) in item.exhibitionEntity" style="position: relative;">
									  <view :style="{background:(ee.fontBackgroundColor?ee.fontBackgroundColor:'#EBEDFF'),opacity: 0.2, borderRadius: '30rpx'}">
										<view style="padding:0 10rpx 0 10rpx;" :style="{color:(ee.fontColor ? ee.fontColor:'#6A76FF'),opacity: 1}">{{ee.exhibitionShortName}}</view>
									  </view>
									  <view style="position:absolute;top:0px;padding:0 10rpx 0 10rpx;" :style="{color:(ee.fontColor ? ee.fontColor:'#6A76FF'),opacity: 1}">{{ee.exhibitionShortName}}</view>
									</view>
								</view>
							</view>
						<!-- <view class="list">
							<navigation class="url" v-for="dd in item.productEntities" :key="dd.id">
								<image class="img" @click="toProductDetail(dd.id)" :src="dd.banarImg" mode="widthFix" />
							</navigation>
						</view> -->
					</view>
				</view>
			</view>
			<view v-if="demandInfo.demandState === 1"
				style="background: linear-gradient(306deg, #FFFFFF 48%, #E2EAFE 124%); position: fixed;bottom: 0%; width: 100%;">
				<view style="display: flex; align-items: center;  height: 144rpx;border-radius: 16rpx 16rpx 0rpx 0rpx;" v-if="demandInfo.ifMember==0">
				<view>
					<image class="canyuImg" src="https://m.nocexpo.com/statics/js/modules/h5/img/zuo.png"></image>
				</view>
				<view class="contactNotice">
					<view style="display: flex; font-size: 28rpx;font-weight: 600; ">已经参与 <view style="color: rgb(252, 82, 96);">{{demandInfos}}</view> 家企业
					</view>
					<view style="color: rgb(252, 82, 96);">{{count}}</view>
					<view
					style="color: #A1A0A0;"
						v-if="currentUser.type==1 && currentUser.state==1 && demandInfo.ifDistribution == 0 && ruleWordShow"
						@click="showRule()">{{demandRuleText ? demandRuleText : '规则'}}</view>
				</view>
				<view v-if="currentUser.type==1 && currentUser.state==1">
					<view class="freeAccess" v-if="joinFlag && ifReachLimit" @click="saveDemandContactClick()">
						免费获取
					</view>
					<view v-else class="matching">
						匹配中...
					</view>
				</view>
				</view>
				<view style="background: linear-gradient(352deg, #FFFFFF 0%, #FFF5E3 100%);display: flex; align-items: center; height: 144rpx;border-radius: 16rpx 16rpx 0rpx 0rpx; " v-if="demandInfo.ifMember==1">
				<view>
					<image class="canyuImg" :src="imgUrl + '/statics/js/modules/applet/img/vip1.png'"></image>
				</view>
				<view class="contactNotice">
					<view style="display: flex; color: #8F421B; font-size: 28rpx;font-weight: 600; ">已经参与<view style="color: rgb(252, 82, 96);">{{demandInfos}}</view> 家企业
					</view>
					<view style="color: rgb(252, 82, 96);">{{count}}</view>
					<view
					style="color: #EABD7A;"
						v-if="currentUser.type==1 && currentUser.state==1 && demandInfo.ifDistribution == 0 && ruleWordShow"
						@click="showRule()">{{demandRuleText ? demandRuleText : '规则'}}</view>
				</view>
				<view v-if="currentUser.type==1 && currentUser.state==1">
					<image :src="imgUrl + '/statics/js/modules/applet/img/vip2.png'" mode="" style="width: 268rpx; height: 132rpx; padding-right: 32rpx; margin-top: -30rpx;" v-if="joinFlag && ifReachLimit" @click="saveDemandContactClick()"></image>
					<!-- <view class="freeAccess1" >
						免费获取
					</view> -->
					<view v-else class="matching">
						匹配中...
					</view>
				</view>
				</view>
			</view>
			<view @click="toBuy()" v-if="ifShowBottomImg">
				<image mode="widthFix" :src="bottomImg" />
			</view>
			<view v-if="!(compList && compList.length>0) || demandInfo.demandState==1"
				style="background: rgb(255, 255, 255);height: 480rpx;width: 696rpx;margin: 20rpx 18rpx 18rpx 18rpx">
				<view class="item-b" style="text-align: center;">
					<view class="item1">
						<image mode="widthFix" src="https://m.nocexpo.com/statics/js/modules/h5/img/pi.png" />
					</view>
					<view class="item2" style="color: #00AAA6;">匹配中...</view>
					<view style="color: darkgrey;"
						v-if="currentUser.type==1 && currentUser.state==1 && demandInfo.ifDistribution == 1 && ruleWordShow"
						class="item2" @click="showRule()">{{demandRuleText ? demandRuleText : '规则'}}</view>
				</view>
			</view>
		</view>
		<!--全局悬浮-->
<!-- 		<suspension types="group"></suspension> -->
		<uni-popup ref="contact" type="center">
			<view class="contact-module">
				<view class="item">
					<view class="left">
						<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/ren.png" mode="widthFix" />
						<!-- {{item.remark}} -->
						电话
					</view>
					<image
						@click="callPhone(6, currentUser.id, demandInfo.id, 2,vender.phone, 0, currentUser.type, currentUser.state)"
						class="right" src="https://m.nocexpo.com/statics/js/modules/h5/img/phono.png" mode="widthFix" />
				</view>

				<view class="text">联系我时，请说明是“金诺云展”推荐的，谢谢</view>
			</view>
			<view class="contact-close" style="height: 33px;" @click="$refs.contact.close()">
				<image class="img" src="https://m.nocexpo.com/statics/js/modules/h5/img/closs.png" mode="widthFix" />
			</view>
		</uni-popup>
		<uni-popup ref="rule" type="center">
			<view style="background-color: white;width: 600rpx;border-radius: 30rpx;text-align: center;">
				<view style="font-size: 30rpx;text-align: left;padding: 85rpx 35rpx 70rpx 35rpx;">
					<rich-text :nodes="sysConfig.paramValue"></rich-text>
				</view>
				<view style="padding: 10rpx;">
					<view class="showRule" @click="$refs.rule.close()">
						我知道了
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import demandApi from '@/api/demand.js';
	import detailApi from '@/api/demanddetail.js'
	import commonApi from '@/utils/commonMethod.js'
	import indexApi from '@/utils/request/index.js';
	export default {

		data() {
			return {
				dengdai: false,
				demandInfos: 0,
				xinxiShow: false,
				saveDemand: true,
				count: '', //倒计时
				seconds: '', // 10天的秒数
				register: false, //登录
				currentUser: {},
				demandId: '',
				concludeCompanyId: '',
				ifPurchase: '',
				demandInfo: {},
				ifDistribution: '',
				isShowFriend: false,
				ifCollected: false,
				collection: {},
				sysConfig: {},
				vender: {},
				attentionFlag: true, //是否关注
				likeProductList: [],
				contactFlag: false, //联系方式是否显示
				compList: [],
				showContactCompany: false,
				showDistributionCompany: false,
				// videoShow:false,
				// haveTag:false,
				joinFlag: true, //参与状态
				ifReachLimit: true, // 公开配置数量大于参与数量
				ruleShow: false, //显示规则内容
				ruleWordShow: false, //显示规则文字
				configs: [],
				demandMinScore: '', //获取需求最低分
				ifMemberUser: false, //非会员获取会员需求弹窗判断
				ifRemainNumber: false, //会员的会员需求是否还有
				demandRuleText: '', //规则弹窗按钮文字显示
				supplierListName: '', //参与需求供应商列表列名文字显示

				share_url: '',
				verifyFlag: true,
				bottomImg: '', //底部图链接
				bottomImgUrl: '', //底部图跳转链接
				bottomImgToType: '', //底部图显示客户类型，1：只显示给供应商，2：只显示给非供应商
				ifShowBottomImg: false,

				startTime: '', //进入页面时间
				endTime: '', //离开页面时间
				currentUrl: '', //当前页面全路径

				ifConform: true,
				imgUrl: indexApi.baseUrl,
				pipei:"",

				share_title:'',
				share_desc: '',

			};
		},

		async onLoad(options) {
			this.demandId = options.demandId;
			this.register = await commonApi.getUserLoginFlag();

			if (this.register) {
				this.dialogToggle('success')

			}

		},
		onShow() {
			setTimeout(() => {

				if (getApp().globalData.onShow) {
					getApp().globalData.onShow = 0;
					console.log("demo前后台切换之切到前台")
				} else {
					console.log("demo页面被切换显示")
					this.startTime = +new Date();
				}

			}, 100);
		},
		onHide() {
			setTimeout(() => {
				var that = this
				if (getApp().globalData.onHide) {
					getApp().globalData.onHide = 0;
					console.log("还在当前页面活动")
				} else {
					that.endTime = +new Date();
					console.log("demo页面停留时间：" + (that.endTime - that.startTime))
					var stayTime = Math.round((that.endTime - that.startTime) / 1000);
					//这里获取到页面停留时间stayTime，然后了可以上报了
					this.saveFootPrint(stayTime);
				}
			}, 100)
		},
		onUnload() {
			setTimeout(() => {
				var that = this
				if (getApp().globalData.onHide) {
					getApp().globalData.onHide = 0;
					console.log("还在当前页面活动")
				} else {
					that.endTime = +new Date();
					console.log("demo页面停留时间：" + (that.endTime - that.startTime))
					var stayTime = Math.round((that.endTime - that.startTime) / 1000);
					//这里获取到页面停留时间stayTime，然后了可以上报了
					this.saveFootPrint(stayTime);
				}
			}, 100)

		},
		async mounted() {

			const currentPromise = await commonApi.currentUserAxios()
			this.currentUser = currentPromise.data.session_user_h5
			await this.getDemandDetail();
			await this.verifyProductCount(currentPromise.data.session_user_h5)
			// await this.getCurrentUser()
			this.time();
			await this.getConfig();
			await this.getSetLimit();
			const pages = getCurrentPages()
			const currentPage = pages[pages.length - 1]
			this.share_url = currentPage.$page.fullPath
			await this.getIfConformTags();
			if(this.currentUser.phone != null){
				await this.queryContactFlag();
			}
			await commonApi.recordBrowse(2,this.currentUser.id,this.demandId,2)
			commonApi.getPageShareConfig().then(res =>{
				  res.data.list.forEach((value, index, array) => {
					if (value.pageParam.includes("demand_detail")) {
						if (value.shareTitleConfig != null && value.shareTitleConfig != '') {
							this.share_title = value.shareTitleConfig
						}
						if (value.shareDescConfig != null && value.shareDescConfig != '') {
							this.share_desc = value.shareDescConfig
						}
					}
				})
			})
		},
		onShareAppMessage: function() { //分享

			return {
				title: this.demandInfo.classifyName != null ? this.demandInfo.classifyName + ':' + this.demandInfo.title.substr(0, 50) + '_' + this.share_title : '寻求：' + this.demandInfo.title.substr(0, 50) + '_' + this.share_title,
				path: this.share_url + '&sourceUserId=' + uni.getStorageSync("userId"),
				desc: this.demandInfo.content,
				imageUrl: this.demandInfo.imgList.length > 0 ? this.demandInfo.imgList[0] : 'https://m.nocexpo.com/statics/js/modules/h5/img/demandshare.jpg',
				success: function(res) {
					console.info(res + '成功');
					wx.showToast({
						title: '分享成功',
					})
					// 转发成功
				},
				fail: function(res) {
					console.log(res + '失败');
					// 转发失败
				},

			}
		},
		/*分享朋友圈 */
		onShareTimeline: function() {
			return {
				title: this.demandInfo.classifyName != null ? this.demandInfo.classifyName + ':' + this.demandInfo.title.substr(0, 50) + '_' + this.share_title : '寻求：' + this.demandInfo.title.substr(0, 50) + '_' + this.share_title,
				query: 'demandId=' + this.demandId + '&sourceUserId=' + uni.getStorageSync("userId"),
				imageUrl: this.demandInfo.imgList.length > 0 ? this.demandInfo.imgList[0] : 'https://m.nocexpo.com/statics/js/modules/h5/img/demandshare.jpg',
			}
		},
		methods: {
			dialogClose() {
							uni.navigateBack()
						},
			dialogToggle(type) {
							this.msgType = type
							this.$refs.alertDialog.open()
						},
			dialogConfirm() {
				if (this.register) {
					uni.redirectTo({
						url: '/pages/account/login/login?demandId='+this.demandId,
					})
				}else{
					uni.navigateTo({
						url:'/pages/need/detail/detail?demandId=' + this.demandId
					})
				}
					this.$refs.message.open()
			},
			saveFootPrint(stayTime) {
				commonApi.saveFootPrint(this.currentUser.id, this.startTime, stayTime, this.share_url, "需求详情")

			},
			open() {
						this.$refs.popup.open()
					},
			toBuy() {
				uni.redirectTo({
					// url: '/pages/need/member/memberDemand'
					url: this.bottomImgUrl

				})
			},
			goTagNews(item) {
				uni.navigateTo({
					url: '/pages/product/tag/tagNewsList?activeIndex=3&tagId=' + item.id,

				})
				// window.location.href = '/h5/tagNewsList.html?activeIndex=3&tagId=' + item.id;
			},
			callPhone(type, userId, businessId, businessType, phone, phoneIndex, userType, userState) {
				commonApi.callPhone(type, userId, businessId, businessType, phone, phoneIndex, userType, userState)
			},
			async getCurrentUser() {
				commonApi.currentUserAxios().then(res => {
					this.currentUser = res.data.session_user_h5;
					this.verifyProductCount(res.data.session_user_h5)
				});
			},
			async getDemandDetail() {
				await detailApi.getDemandDetail(this.demandId).then(res => {
					this.demandInfo = res.data.nocDemand;
					if(this.demandInfo.delFlag == 4){
						uni.showToast({
							title: "该需求已下架",
							icon: 'none',
							duration: 2000
						});
						setTimeout(function () {
							uni.redirectTo({
								url: '/pages/need/list/list'
							})
						}, 2000)
					}else if(this.demandInfo.delFlag == 1){
						uni.showToast({
							title: "该需求已关闭",
							icon: 'none',
							duration: 2000
						});
						setTimeout(function () {
							uni.redirectTo({
								url: '/pages/need/list/list'
							})
						}, 2000)
					}

					if (this.demandInfo.ifDistribution == 1) {
						this.demandInfos = this.demandInfo.distributions;
						//判断当前登录用户是否参与
						this.queryDistribution()
					} else if (this.demandInfo.ifDistribution == 0) {
						this.demandInfos = this.demandInfo.contacts;
						//判断当前登录用户是否参与
						if(this.currentUser.phone != null){
							this.queryContact();
						}

					}
					this.seconds = (this.demandInfo.endTimeStamp / 1000) + 7

					this.ifDistribution = this.demandInfo.ifDistribution;
					this.compList = [];
					if (null != this.demandInfo.pictureUrl) {
						this.demandInfo.imgList = this.demandInfo.pictureUrl.split(',');
						for(let i = this.demandInfo.imgList.length - 1; i >= 0; i--){
							if(this.demandInfo.imgList[i].length <= 0){
								this.demandInfo.imgList.splice(i,1)
							}
						}
					}
					if (null != this.demandInfo.videoUrl) {
						if(this.demandInfo.videoUrl.substr(0,1) == ","){
							this.demandInfo.videoUrl = this.demandInfo.videoUrl.substr(1)
						}

						this.demandInfo.videoList = this.demandInfo.videoUrl.split(',');
						console.log(this.demandInfo.videoList)
					}
					detailApi.getVender(this.demandInfo.userId).then(res => {
						this.vender = res.data.nocUser
					})

					this.queryCompany();
				});

			},
			// 天 时 分 秒 格式化函数
			countDown() {
				// let d = parseInt(this.seconds / (24 * 60 * 60))
				// d = d < 10 ? "0" + d : d
				let h = parseInt(this.seconds / (60 * 60) % 24);
				h = h < 10 ? "0" + h : h
				let m = parseInt(this.seconds / 60 % 60);
				m = m < 10 ? "0" + m : m
				let s = parseInt(this.seconds % 60);
				s = s < 10 ? "0" + s : s
				this.count = '剩余: ' + h + '小时' + m + '分钟' + s + '秒'
			},
			//定时器没过1秒参数减1
			time() {
				var myTimer = setInterval(() => {
					if (this.demandInfo.endTimeStamp > 0) {
						this.seconds -= 1
						if (this.seconds > 0) {
							this.countDown()
						} else {
							this.seconds = 0
							this.getDemandDetail()
							clearInterval(myTimer);
						}
					}
				}, 1000)
			},
			toShowroom(id) {
				uni.redirectTo({
					url: '/pages/product/showroom/showroom?userId=' + id
				})
			},
			getConfig() {
				commonApi.getConfig().then(res => {
					let configlist = [...res.data.list]
					configlist.forEach((value, index, array) => {
						if (value.paramKey === "demand_rule_config") {
							this.sysConfig.paramValue = decodeURIComponent(value.paramValue);
							if (this.sysConfig.paramValue != null && this.sysConfig.paramValue != '') {
								this.ruleWordShow = true;
							}
						} else if (value.paramKey == 'demand_rule_text') {
							this.demandRuleText = value.paramValue;
						} else if (value.paramKey == 'participation_demand_list_title') {
							this.supplierListName = value.paramValue;
						} else if (value.paramKey == "demand_min_score_public" && this.demandInfo
							.ifDistribution == 0) {
							this.demandMinScore = value.paramValue;
						} else if (value.paramKey == "demand_min_score" && this.demandInfo
							.ifDistribution == 1) {
							this.demandMinScore = value.paramValue;
						} else if (value.paramKey == 'demand_detail_bottom_img') {
							this.bottomImg = value.paramValue
						} else if (value.paramKey == 'demand_img_applet_url') {
							this.bottomImgUrl = value.paramValue
						} else if (value.paramKey == 'demand_detail_img_show') {
							this.bottomImgToType = value.paramValue
						}

					})
					if (this.bottomImgToType == 1 && this.currentUser.type == 1 && this.currentUser.state == 1) {
						this.ifShowBottomImg = true
					} else if (this.bottomImgToType == 2 && this.currentUser.type != 1) {
						this.ifShowBottomImg = true
					}

				})
			},
			showRule() {
				this.$refs.rule.open();

			},
			async toCall() {

				if(!this.ifReachLimit && this.joinFlag){
					uni.showToast({
						title: "该需求已报满，请获取其他需求",
						icon:'none',
						duration:2000
					});
					return;
				}

				if (this.joinFlag) {
					uni.showToast({
						title: "请先点击下方“免费获取”按钮，参与需求",
						icon: 'none',
						duration: 2000
					});
					return;
				}
				if (this.demandInfo.ifDistribution == 1) {
					if (this.demandInfo.ifPurchase != 2) {
						uni.showToast({
							title: "请选择状态为“对接中”的需求联系",
							icon: 'none',
							duration: 2000
						});
						return;
					}
					if (!this.contactFlag) {
						uni.showToast({
							title: "您参与的该需求选配失败",
							icon: 'none',
							duration: 2000
						});
						return;
					}
				}



				this.$refs.contact.open();
			},
			getSetLimit() {
				detailApi.getSetLimit(this.demandId).then(res => {
					this.ifReachLimit = res.data.ifReachLimit
				})
			},
			getIfConformTags() {
				detailApi.getIfConformTags(this.demandId).then(res => {
					if (res.data.list == null || res.data.list == '') {
						this.ifConform = false;
					} else {
						this.ifConform = true;
					}
				})
			},
			verifyProductCount(currentUser) {
				if (currentUser.type == 1 && currentUser.state == 1) {
					detailApi.verifyProductCount(currentUser.id).then(res => {
						if (res.data.count < 4) {
							this.verifyFlag = false
						} else {
							this.verifyFlag = true
						}
					})
				}
			},
			saveDistributionUseMember() {
				detailApi.saveDistributionUseMember(this.demandId).then(res => {

				})
			},
			tipBox() {
				//参阅成功就，文字提示弹窗
				uni.showToast({
					title: "若您匹配成功，请在48小时内联系采购方。未及时联系将取消资格。",
					icon: 'none',
					duration: 2000
				});
			},
			saveDemandDistribution() {
				detailApi.saveDemandDistribution(this.demandId).then(res => {

				})
			},
			saveDemandContact() {
				detailApi.saveDemandContact(this.demandId).then(res => {
					if(res.data.code == 0){
						this.getDemandDetail()
						this.tipBox()
					}else{
						this.getDemandDetail()

						uni.showToast({
							"title": res.data.msg,
							"icon": "none",
						});

					}
				})
			},
			// async sendMsg(){
			// 	//跳转发送消息
			//
			// 	//判断是否登录
			// 	this.register = await commonMethod.getUserLoginFlag();
			// 	if (this.register) {
			// 	  uni.redirectTo({
			// 	    url: '/pages/account/login/login'
			// 	  })
			// 	}else{
			// 		//跳转到消息
			// 	}
			// },
			async showServiceTelList() {
				//显示电话列表

				this.register = await commonMethod.getUserLoginFlag();
				if (this.register) {
					uni.redirectTo({
						url: '/pages/account/login/login'
					})
				} else {
					//电话列表弹窗
				}
			},
			async saveDemandContactClick() {
				if (this.demandInfo.ifMember == 1) {
					if (this.currentUser.remainNumber == 0 || this.currentUser.ifMember == 0) {
						// this.ifMemberUser = true;
						//提示暂无相关产品，请立即更新
						uni.showModal({
							title: "",
							content: "剩余会员需求数不足",
							showCancel: false,
							confirmText: "去购买",
							success: function(res) {
								if (res.confirm) {
									uni.redirectTo({
										url: '/pages/need/member/memberDemand'
									})
									console.log('用户点击确定');
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						});

						return;
					}
				}
				if (!this.ifConform) {
					//提示暂无相关产品，请立即更新
					uni.showModal({
						title: "",
						content: "您店铺无该商品，活跃值较低，请上传后获取",
						showCancel: false,
						confirmText: "我知道了",
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					console.log("弹窗");
					// this.haveTag = true;
					return;
				}

				if (!this.verifyFlag || this.currentUser.score < this.demandMinScore) {
					//提示产品数量不够，或者活跃度不够
					uni.showModal({
						title: "",
						content: "您店铺无该商品，活跃值较低，请上传后获取",
						showCancel: false,
						confirmText: "我知道了",
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					// this.videoShow = true ;
					return;
				}
				if (this.demandInfo.ifDistribution == 1 && this.demandInfo.ifMember == 0 && this.currentUser
					.ifMember == 1) {
					//提示是否使用会员权益
					uni.showModal({
						title: "",
						content: "是否使用会员权益获取该需求？",
						showCancel: true,
						confirmText: "确定",
						cancelText: "普通获取",
						success: function(res) {
							var that = this
							if (res.confirm) {
								console.log('用户点击确定');
								that.compList = []
								that.saveDemand = false //没找到地方使用
								that.saveDistributionUseMember()
								that.getDemandDetail()
								that.tipBox();
							} else if (res.cancel) {
								console.log('用户点击取消');
								that.compList = []
								that.saveDemand = false
								that.saveDemandDistribution()
								that.getDemandDetail()
								that.tipBox()
							}
						}.bind(this)
					});

				} else if (this.demandInfo.ifDistribution == 1 && this.demandInfo.ifMember == 1 && this.currentUser
					.ifMember == 1) {
					uni.showModal({
						title: "",
						content: "您确定要获取该需求？",
						showCancel: true,
						confirmText: "确定",
						cancelText: "取消",
						success: function(res) {
							var that = this
							if (res.confirm) {
								console.log('用户点击确定');
								console.log(that.demandInfo);
								that.compList = []
								that.saveDemand = false //没找到地方使用
								that.saveDistributionUseMember()
								that.getDemandDetail()
								that.tipBox()
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}.bind(this)
					});
				} else {
					//普通获取
					uni.showModal({
						title: "",
						content: "您确定要免费获取该需求？",
						showCancel: true,
						confirmText: "确定",
						cancelText: "取消",
						success: function(res) {
							var that = this
							if (res.confirm) {
								console.log('用户点击确定');
								console.log(that.demandInfo);
								that.compList = []
								that.saveDemand = false //没找到地方使用
								if (that.demandInfo.ifDistribution == 1) {
									that.saveDemandDistribution()
									that.getDemandDetail()
									that.tipBox()
								}
								if (that.demandInfo.ifDistribution == 0) {
									that.saveDemandContact()
								}

							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}.bind(this)
					});
				}

			},
			queryContactFlag() {
				detailApi.queryContactFlag(this.demandId).then(res => {
					let list = res.data.list;
					if (list && list.length > 0) {
						this.contactFlag = true;
					} else {
						this.contactFlag = false;
					}
				})
			},
			getDealCompany() {
				detailApi.getDealCompany(this.demandId).then(res => {
					this.concludeCompanyId = res.data.nocDemandEntity.concludeCompanyId
					this.ifPurchase = res.data.nocDemandEntity.ifPurchase
				})
			},
			queryContact() {
				detailApi.queryContact(this.demandId).then(res => {
					if (res.data.size > 0) {
						this.joinFlag = false;
					} else {
						this.joinFlag = true;
					}
				})
			},
			queryDistribution() {
				detailApi.queryDistribution(this.demandId).then(res => {
					if (res.data.size > 0) {
						this.joinFlag = false;
					} else {
						this.joinFlag = true;
					}
				})
			},
			queryCompany() {
				detailApi.queryCompany(this.ifDistribution, this.demandId).then(res => {
					this.compList = [...this.compList, ...res.data.list];
					//处理服务地区
					console.log(res);
					this.pipei=res.data.list.length
					for (let i = 0; i < this.compList.length; i++) {
						let userAddress = this.compList[i].nocUserEntity.serviceArea;
						if (null != userAddress) {
							let address = userAddress.split(",");
							let showAddress = [];
							for (let j = 0; j < address.length; j++) {
								let split = address[j].split("、");
								for (let j = split.length - 1; j >= 0; j--) {
									if (split[j] != "") {
										showAddress.push(split[j])
										break;
									}
								}
							}
							this.compList[i].nocUserEntity["showAddress"] = showAddress
						}
					}
					if (this.compList.length > 0) {
						this.showContactCompany = true;
					}
				})
			},
			async sendMsg() {

				if (this.joinFlag) {
					uni.showToast({
						title: "请先点击下方“免费获取”按钮，参与需求",
						icon: 'none',
						duration: 2000
					});
					return;
				}
				if (this.demandInfo.ifDistribution == 1) {
					if (this.demandInfo.ifPurchase != 2) {
						uni.showToast({
							title: "请选择状态为“对接中”的需求联系",
							icon: 'none',
							duration: 2000
						});
						return;
					}
					if (!this.contactFlag) {
						uni.showToast({
							title: "您参与的该需求选配失败",
							icon: 'none',
							duration: 2000
						});
						return;
					}
				}
				//判断是否登录
				this.register = await commonApi.getUserLoginFlag();
				if (this.register) {
					uni.redirectTo({
						url: '/pages/account/login/login',
					})
				}
				uni.redirectTo({
					url: '/pages/news/chatDetail/chatDetail?toUserId=' + this.demandInfo.userId +
						'&demandId=' + this.demandInfo.id
				})
			},
			toProductDetail(productId) {
				console.log("chanpinxiangqing");
				uni.redirectTo({
					url: '/pages/product/productDetail/productDetail?productId=' + productId
				})
			}

		}
	};
</script>

<style lang="scss">
	.flow_img{
		width: 64rpx;
		height: 64rpx;
		display: block;
		margin: 0 auto;
	}
	.flow_path{
		width: 96%;
		margin: 0 auto;
		margin-top: 30rpx;
		display: flex;
		align-items: center;
		justify-content: space-around;
		.flow_mod{
			width: 120rpx;
			text-align: center;
			font-size: 26rpx;
			color: #A1A0A0;
			font-weight: 400;
		}
		.flow_j{
			width: 47.68rpx;
			height: 31.66rpx;
		}
	}
	.flow_l_i {
		width: 6rpx;
		height: 26rpx;
		// background-image: url(../../a);
		border-top-right-radius: 200rpx;
		border-bottom-right-radius: 200rpx;
		background-color: #00B7B3;
		position: absolute;
		left: 0;
		top: 50%;
		margin-top: -13rpx;
	}

	.flowline {
		width: 686rpx;
		height: 0px;
		border-bottom: 2rpx solid #f7f7f7;
		float: right;
	}

	.flowtitle {
		width: 100%;
		height: 84rpx;
		line-height: 84rpx;
		font-size: 28rpx;
		font-weight: normal;
		color: #2E2D2D;
		box-sizing: border-box;
		padding-left: 30rpx;
		position: relative;
	}

	.flowbox {
		margin-top: 16rpx;
		width: 100%;
		height: 135px;
		border-radius: 20rpx;
		// background: linear-gradient(160deg, #E6F9F9 0%, #FFFFFE 50%);
		.tu{
			width: 750rpx;
			height: 270rpx;
		}
	}


	.header {
		height: 100rpx;
		display: flex;
		align-items: center;
		background-color: #ffffff;

		.avatar {
			width: 50rpx;
			height: 50rpx;
			border-radius: 50%;
		}

		.username {
			margin-left: 10rpx;
			font-size: 30rpx;
			font-weight: 700;
		}

		.left-icon {
			padding: 20rpx 10rpx;
		}

	}

	.contact-close {
		padding: 48rpx;
		text-align: center;

		.img {
			width: 60rpx;
		}
	}

	.contact-module {
		width: 594rpx;
		background: linear-gradient(180deg, #e2f9f9 0%, #ffffff 100%);
		border-radius: 36rpx;
		padding-top: 70rpx;
		padding-bottom: 48rpx;

		.item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 50rpx;


			.left {
				flex: 1;
				display: flex;
				align-items: center;
				font-size: 36rpx;
				margin-left: 34rpx;

				.name {
					text-overflow: ellipsis;
					white-space: nowrap;
					overflow: hidden;
					width: 0px;
					flex: 1;
				}

				.img {
					width: 100rpx;
					height: 100rpx;
					margin-right: 24rpx;
					border-radius: 50%;
				}
			}

			.right {
				margin-left: $interval;
				width: 48rpx;
				margin-right: 46rpx;
			}
		}

		.text {
			color: $text-color-grey;
			font-size: 28rpx;
			padding: 18rpx 34rpx;
			text-align: center;
			background: linear-gradient(270deg, #ffffff 0%, #ecf8f8 100%);
			border-radius: 8rpx;
			margin: 0px 36rpx;
		}
	}

	.canyuImg {
		width: 80rpx;
		height: 80rpx;
		margin-left: 50rpx;
	}

	.contactNotice {
		width: 450rpx;
		margin-left: 24rpx;
	}

	.freeAccess {
		width: 200rpx;
		// height: 75rpx;
		background: linear-gradient(90deg, #265FFF 0%, #97B3FF 100%);
		border-radius: 60rpx;
		line-height: 70rpx;
		text-align: center;
		font-weight: 700;
		color: #FFFFFF;
		font-size: 32rpx;
		margin-right: 30rpx;



	}

	.matching {
		width: 200rpx;
		height: 75rpx;
		// background: linear-gradient(90deg, #265FFF 0%, #97B3FF 100%);
		background: rgb(242, 243, 245);
		border-radius: 60rpx;
		line-height: 70rpx;
		text-align: center;
		font-weight: 700;
		color: #FFFFFF;
		font-size: 32rpx;
		margin-right: 30rpx;
	}

	.scroll-view {
		// height: calc(100% - 100rpx);
		padding-bottom:80rpx;
		box-sizing: border-box;
		display: block;
		.module {
			background: linear-gradient(312deg, #ffffff 0%, #e3f3f3 100%);
			border-radius: 0rpx 0rpx 20rpx 20rpx;
			// padding: $interval 0px $interval $interval;
			border-radius: 0rpx 0rpx 20rpx 20rpx;

			.title {
				display: flex;
				justify-content: space-between;
				margin-bottom: 12rpx;

				.text {
					flex: 1;
					display: flex;
					align-items: center;
					position: relative;
					font-weight: 700;
					font-size: $font-size-max;

					word-break: break-all;

					text-overflow: ellipsis;

					display: -webkit-box;

					-webkit-box-orient: vertical;

					-webkit-line-clamp: 2;
					/* 这里是超出几行省略 */

					overflow: hidden;

					.rz {
						height: 32rpx;
						margin-right: 12rpx;
					    margin-top: 6rpx;
					}
					.rz1{
						width: 30px;
						height: 40rpx;
					}
				}

				.rightImg {
					height: 48rpx;
					margin-left: $interval;
					;
				}
			}

			.attr {
				color: #2E2D2D;
				margin-top: 15rpx;

				text {
					color: #A1A0A0;
					// font-size: $font-size-min;
					font-size: 13px;
					text-align: center;
				}

			}

			.tags {
				margin-top: 20rpx;
				display: flex;
				//justify-content: flex-start;
        flex-wrap: wrap;

				.t {
					padding: 0px $interval-min;
					line-height: 48rpx;
					background: #F0EEEE;
					border-radius: 8rpx;
					color: #504E4E;
					margin-right: 16rpx;
          margin-top: 10rpx;
					font-size: $font-size-min;
				}
			}
		}

		.pipei {
			font-size: $font-size-max+5;
			font-weight: 600;
			padding: 0rpx 0px 0px 24rpx;
		}

		.ruletext {
			margin-left: 15rpx;
			padding-top: 15rpx;
		}
	}

	.shop-list-data {
		padding: 0px 16rpx;
	}

	.cls {
		display: inline-block;
	}

	.images {
		.img {
			width: 100%;
			display: block;
			margin: 15rpx auto;
		}
	}

	.showRule {
		margin: auto auto 35rpx;
		width: 200px;
		height: 80rpx;
		background: linear-gradient(rgb(84, 214, 210) 0%, rgb(0, 170, 166) 100%);
		font-weight: 700;
		font-size: 30rpx;
		color: rgb(255, 255, 255);
		text-align: center;
		line-height: 80rpx;
		border-radius: 40rpx;
	}

	.module {
		padding: 24rpx 28rpx;
		background-color: #ffffff;
		border-radius: 16rpx;
	}

	image {
		width: 100%;
		vertical-align: top;
	}

	.item-b {
		width: 714rpx;
		height: 480rpx;
		padding-top: 95rpx;
		background: white;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
	 }

	.item-b .item1 {
		margin: auto;
		width: 300rpx;
		height: 196rpx;
	}

	.box .mianfei .item-b .item2 {
		width: 100%;
		text-align: center;
		font-size: 26rpx;
		color: #00AAA6;
	}
	.uni-popup-dialog{
	background: linear-gradient(180deg, #E6F9F9 0%, #FFFFFF 100%);

	}

</style>
